-
Notifications
You must be signed in to change notification settings - Fork 13
Resize block buffer after allocation if significant wasted space #1674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
20a5f65 to
92a7bd0
Compare
GeorgeHahn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Thanks for investigating - this was an interesting finding.
I went back and forth on this, but I do like the idea of resizing all blocks. Some extra work up front to reduce memory usage at runtime is probably the right tradeoff for lading as it runs in SMP jobs. That said, I'm not too sad about the 50% worst case inefficiency either. That's about the same as we could expect from allocating the |
92a7bd0 to
f4e7959
Compare
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|

What does this PR do?
When constructing a block cache, the cache pre-allocates a buffer of max block size for each block. Payload generators then serialize bytes into that buffer. The buffer previously was never resized and thus held onto its excess memory. This made caches with small blocks hold (# blocks * max block size) in memory instead of the specified cache size.
This change resizes blocks that use under half of the pre-allocated space. This should enforce that the buffers of a cache are now no more than 2x the maximum configured cache size.
Motivation
Significant memory usage from my payload generator that has lots of smaller blocks.
Additional notes
We could probably resize every block since this is only done on lading creation anyways - wdyt? 2x was an arbitrary decision here.